<?php
$this->breadcrumbs=array(
	'Admin Panel'=>$this->createUrl( '/adminpanel'),
	'Tenants'=>array('index'),
	$model->id,
);

$this->menu=array(
	array('label'=>'List Tenant', 'url'=>array('index')),
	array('label'=>'Create Tenant', 'url'=>array('create')),
	array('label'=>'Update Tenant', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Tenant', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Tenant', 'url'=>array('admin')),
);
?>
<?php 
$user=User::model()->findByPk($model->iduser);
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/js/tabs.js');
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tabs.css" media="screen, projection" />


<h1><?php echo 'Tenant: '.$user->FirstName.' '.$model->MiddleInitial.' '.$user->LastName ?></h1>
<ul class="tabs">
    <li><a href="#tab1">Overview</a></li>
    <li><a href="#tab2">Occupanscy</a></li>
    <li><a href="#tab3">Co-Tenants</a></li>
</ul>


<div class="tab_container">

<div id="tab1" class="tab_content">
<?php 
$this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		array(
			'name' => 'User Name',
			'value' => $user->userName,
		),
		array(
			'name' => $user->getAttributeLabel('Password'),
			'value' => $user->Password,
		),
		array(
			'name' => $user->getAttributeLabel('FirstName'),
			'value' => $user->FirstName,
		),
		'MiddleInitial',
		array(
			'name' => $user->getAttributeLabel('LastName'),
			'value' => $user->LastName,
		),
		'DateOfBirth',
		array(
			'name' => $user->getAttributeLabel('email'),
			'value' => $user->email,
		),
		'LastFour',
		'OtherLastName',
		'OtherLastName2',
		'LasFreeAcess',
	),
)); ?>
<br><br>


<?php if(Tenantreportedcurrentaddress::model()->exists('idTenant=:t_id', array(':t_id'=>$model->id))) { ?>

<h2> Current Address </h2>
<?php
$this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		array(
			'label' => 'Address',
			'value' => $model->tenantreportedcurrentaddresses->idRentalProperty0->AddressOne.' '.$model->tenantreportedcurrentaddresses->idRentalProperty0->AddressTwo,
		),
		array(
			'label' => 'City',
			'value' => $model->tenantreportedcurrentaddresses->idRentalProperty0->City,
		),
		array(
			'label' => 'State',
			'value' => $model->tenantreportedcurrentaddresses->idRentalProperty0->State,
		),
		array(
			'label' => 'Zip Code',
			'value' => $model->tenantreportedcurrentaddresses->idRentalProperty0->ZipCode,
		),
		array(
			'label' => 'Phone Number',
			'value' => $model->tenantreportedcurrentaddresses->idRentalProperty0->PhoneNumber,
		),
		array(
			'label' => 'Email Address',
			'value' => $model->tenantreportedcurrentaddresses->idRentalProperty0->EmailAddress,
		),
		array(
			'label' => 'Management Company',
			'type'=>'raw',
			'value' =>CHtml::link(CHtml::encode($model->tenantreportedcurrentaddresses->idRentalProperty0->idManagement0->CompanyName),
                                 array('/adminpanel/management/view','id'=>$model->tenantreportedcurrentaddresses->idRentalProperty0->idManagement0->id)),
		),
		array(
			'label' => 'Rental Property',
			'type'=>'raw',
			'value' =>CHtml::link(CHtml::encode($model->tenantreportedcurrentaddresses->idRentalProperty0->id),
                                 array('/adminpanel/rentalproperty/view','id'=>$model->tenantreportedcurrentaddresses->idRentalProperty0->id)),
		),
		array(
			'label' => 'Rental Unit Number',
			'type'=>'raw',
			'value' =>CHtml::link(CHtml::encode($model->tenantreportedcurrentaddresses->idRentalUnit0->UnitNumber),
                                 array('/adminpanel/rentalproperty/view','id'=>$model->tenantreportedcurrentaddresses->idRentalProperty0->id)),
		),
		
		
	),
)); }?>
</div>

<div id="tab2" class="tab_content">
<h2> Occupanscy </h2>
<p> Tenant Occupancy Record. <?php echo CHtml::link(CHtml::encode('Add Occupancy' ), array('/adminpanel/occupancy/create','tid'=>$model->id)); ?> information.

<?php 

$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'occupancy-grid',
	'dataProvider'=>$occupancy,
		'columns'=>array(
		array(            // display 'author.username' using an expression
            'name'=> 'idRentalProperty',
			'header'=>'Rental Property',
			'type'=>'raw',
			'value'=>'CHtml::link($data->idRentalProperty0->AddressOne, array(\'/adminpanel/rentalproperty/view\',\'id\'=>$data->idRentalProperty0->id))',
        ),
		array(            // display 'author.username' using an expression
            'name'=> 'idRentalUnit',
			'header'=>'Rental Unit',
			'type'=>'raw',
			'value'=>'CHtml::link($data->idRentalUnit0->UnitNumber, array(\'/adminpanel/rentalproperty/view\',\'id\'=>$data->idRentalProperty0->id))',
        ),
	
		'MoveInDate',
		'SoftwareTenantNumber',
		'MoveOutDate',
		'LeaseEndDate',
		'Occupancycol',
		array(            // display 'author.username' using an expression
            'name'=> 'MonthToMonthTenancy',
			'value'=>'($data->MonthToMonthTenancy== 1)? \'Yes\':\'No\'',
        ),
		array(
			'class'=>'CButtonColumn',
    'template'=>'{view} {update} {delete}',
    'buttons'=>array
    (
        'view' => array
        (
            'label'=>'View Detail',
            'imageUrl'=>Yii::app()->request->baseUrl.'/assets/a99e585a/gridview/view.png',
            'url'=>'Yii::app()->createUrl("/adminpanel/occupancy/view", array("id"=>$data->id))',
        ),
        'update' => array
        (
            'label'=>'Update Detail',
            'imageUrl'=>Yii::app()->request->baseUrl.'/assets/a99e585a/gridview/update.png',
            'url'=>'Yii::app()->createUrl("adminpanel/occupancy/update", array("id"=>$data->id))',
            
        ),
		
		'delete' => array
        (
            'label'=>'Delete',
            'imageUrl'=>Yii::app()->request->baseUrl.'/assets/a99e585a/gridview/delete.png',
            'url'=>'Yii::app()->createUrl("adminpanel/occupancy/delete", array("id"=>$data->id))',
            
        ),
		
    ),
		),
	),
)); ?>
</div>
	<div id="tab3" class="tab_content">
		<h2>CoTenant</h2> 
		<p>A CoTenant is someone who is legally responsible for the unit, such
			as Spouse, or a roommate (not children).<br><?php echo CHtml::link('Add CoTenant',array('/adminpanel/cotenant/create', 'tid'=>$model->id))?> here.</p>

			<?php
	$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'cotenant-grid',
	'dataProvider'=>$cotenant,
	'columns'=>array(
		'LastName',
		'FirstName',
		'MiddleInitial',
		'DateOfBirth',
		'OnLease',
			array(
			'name'=>'OnLease',
			'value'=>('($data->OnLease== 1)? \'Yes\':\'No\''),
			),
			/*
			 'LastFreeAcess',
			 */
			array(
			'class'=>'CButtonColumn',
    'template'=>'{update} {delete}',
    'buttons'=>array
    (
        
        'update' => array
        (
            'label'=>'Update Detail',
            'imageUrl'=>Yii::app()->request->baseUrl.'/assets/a99e585a/gridview/update.png',
            'url'=>'Yii::app()->createUrl("adminpanel/cotenant/update", array("id"=>$data->id))',
            
        ),
		
		'delete' => array
        (
            'label'=>'Delete',
            'imageUrl'=>Yii::app()->request->baseUrl.'/assets/a99e585a/gridview/delete.png',
            'url'=>'Yii::app()->createUrl("adminpanel/cotenant/delete", array("id"=>$data->id))',
            
        ),
		
    ),
		),
			),
	)); ?>

	</div>
</div>